package view.test;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Point;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import model.GameModel;
import util.SpriteUtils;
import controller.BankType;
import controller.GameController;

/**
 * The view representation of the 
 * bin.
 *
 */
public class ViewBin extends JPanel {

	private static final long serialVersionUID = -3172748503169078929L;
	private static final Dimension MIN_SIZE = new Dimension(192, 192);
	private static final Point LOCATION = new Point(608, 8);
	
	private ImageIcon sourceSprite;
	private ImageIcon mirrorSprite;
	private GlassPane pane;
		
	public ViewBin(GameController controller, GameModel model, GlassPane pane) {
		
		this.pane = pane;
		this.setMinimumSize(MIN_SIZE);
		this.setSize(MIN_SIZE);
		this.setLayout(new GridLayout(2, 2));
		this.setLocation(LOCATION);
		this.setBackground(Color.WHITE);
		this.setVisible(true);
		
		loadSprites();
		
		fillBin(controller, model);
		
	}
	
	private void loadSprites() {
		
		mirrorSprite = SpriteUtils.loadSprite("/MIRROR_VERT.png",this);
		sourceSprite = SpriteUtils.loadSprite("/source_top.png", this);
		
	}
	
	private void fillBin(GameController controller, GameModel model) {
		this.add(new BinBank(model, controller, BankType.SOURCE, Color.RED, sourceSprite, pane));
		this.add(new BinBank(model, controller, BankType.SOURCE, Color.GREEN, sourceSprite, pane));
		this.add(new BinBank(model, controller, BankType.SOURCE, Color.BLUE, sourceSprite, pane));
		this.add(new BinBank(model, controller, BankType.MIRROR, Color.BLACK, mirrorSprite, pane));
	}

}
